/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       discrete_event.h

	$Header: /game/discrete_event.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( DISCRETE_EVENT_H_INCLUDED )
#define DISCRETE_EVENT_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <cassert>
#include <string>

#include "material_array.h"
#include "script_event.h"

class t_player;
class t_adventure_frame;

// --------------------------------------------------------------------------
// t_discrete_event class
// --------------------------------------------------------------------------

class t_discrete_event : public t_script_event
{
public:
	// Constructor/Destructor
	t_discrete_event();
	virtual ~t_discrete_event() = 0;

	// Member functions
	int					get_material_amount( t_material material ) const;
	std::string const &	get_message() const;

	void				execute_effects(t_player& current_player, t_adventure_frame* frame) const;

protected:
	// Member functions
	bool	read(
				std::streambuf &	stream,
				int					version );
	bool	read_from_map(
				std::streambuf &	stream,
				int					format_version );
	bool	write( std::streambuf & stream ) const;

private:
	// Data members
	t_material_array   	m_material_amounts;
	std::string			m_message;
};

// --------------------------------------------------------------------------
// t_discrete_event inline members
// --------------------------------------------------------------------------

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline t_discrete_event::~t_discrete_event()
{
}

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline int t_discrete_event::get_material_amount( t_material material ) const
{
	assert( material >= 0 && material < k_material_count );
	return m_material_amounts[ material ];
}

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline std::string const & t_discrete_event::get_message() const
{
	return m_message;
}

#endif // !defined( DISCRETE_EVENT_H_INCLUDED )
